std::is

您所在的位置:网站首页 std::string empty std::is

std::is

2023-03-17 21:34| 来源: 网络整理| 查看: 265

  C++ Compiler support Freestanding and hosted Language Standard library Standard library headers Named requirements Feature test macros (C++20) Language support library Concepts library (C++20) Metaprogramming library (C++11) Diagnostics library General utilities library Strings library Containers library Iterators library Ranges library (C++20) Algorithms library Numerics library Localizations library Input/output library Filesystem library (C++17) Regular expressions library (C++11) Concurrency support library (C++11) Technical specifications Symbols index External libraries [edit]  Metaprogramming library Type traits Type categories is_void(C++11) is_null_pointer(C++14)   is_array(C++11) is_pointer(C++11) is_enum(C++11) is_union(C++11) is_class(C++11) is_function(C++11) is_object(C++11) is_scalar(C++11) is_compound(C++11) is_integral(C++11) is_floating_point(C++11)   is_fundamental(C++11) is_arithmetic(C++11) is_reference(C++11) is_lvalue_reference(C++11) is_rvalue_reference(C++11) is_member_pointer(C++11) is_member_object_pointer(C++11) is_member_function_pointer(C++11) Type properties is_const(C++11) is_volatile(C++11) is_empty(C++11) is_polymorphic(C++11) is_final(C++14) is_abstract(C++11) is_aggregate(C++17) is_implicit_lifetime(C++23) is_trivial(C++11) is_trivially_copyable(C++11) is_standard_layout(C++11) is_literal_type(C++11)(until C++20) is_pod(C++11)(deprecated in C++20) is_signed(C++11) is_unsigned(C++11) is_bounded_array(C++20) is_unbounded_array(C++20) is_scoped_enum(C++23) has_unique_object_representations(C++17) Type trait constants integral_constantbool_constanttrue_typefalse_type(C++11)(C++17)(C++11)(C++11) Metafunctions conjunction(C++17) disjunction(C++17) negation(C++17) Supported operations is_constructibleis_trivially_constructibleis_nothrow_constructible(C++11)(C++11)(C++11) is_default_constructibleis_trivially_default_constructibleis_nothrow_default_constructible(C++11)(C++11)(C++11) is_copy_constructibleis_trivially_copy_constructibleis_nothrow_copy_constructible(C++11)(C++11)(C++11) is_move_constructibleis_trivially_move_constructibleis_nothrow_move_constructible(C++11)(C++11)(C++11) is_assignableis_trivially_assignableis_nothrow_assignable(C++11)(C++11)(C++11) is_copy_assignableis_trivially_copy_assignableis_nothrow_copy_assignable(C++11)(C++11)(C++11) is_move_assignableis_trivially_move_assignableis_nothrow_move_assignable(C++11)(C++11)(C++11) is_destructibleis_trivially_destructibleis_nothrow_destructible(C++11)(C++11)(C++11) has_virtual_destructor(C++11) is_swappable_withis_swappableis_nothrow_swappable_withis_nothrow_swappable(C++17)(C++17)(C++17)(C++17) Relationships and property queries is_same(C++11) is_base_of(C++11) is_convertibleis_nothrow_convertible(C++11)(C++20) is_layout_compatible(C++20) is_pointer_interconvertible_base_of(C++20) is_pointer_interconvertible_with_class(C++20)   is_corresponding_member(C++20) reference_constructs_from_temporary(C++23) alignment_of(C++11) rank(C++11) extent(C++11) is_invocableis_invocable_ris_nothrow_invocableis_nothrow_invocable_r(C++17)(C++17)(C++17)(C++17) reference_converts_from_temporary(C++23) Type modifications remove_cvremove_constremove_volatile(C++11)(C++11)(C++11) add_cvadd_constadd_volatile(C++11)(C++11)(C++11) make_signed(C++11) make_unsigned(C++11) remove_reference(C++11) add_lvalue_referenceadd_rvalue_reference(C++11)(C++11) remove_pointer(C++11) add_pointer(C++11) remove_extent(C++11) remove_all_extents(C++11) Type transformations aligned_storage(C++11)(deprecated in C++23) aligned_union(C++11)(deprecated in C++23) decay(C++11) remove_cvref(C++20) enable_if(C++11) void_t(C++17) conditional(C++11) common_type(C++11) common_reference(C++20) underlying_type(C++11) result_ofinvoke_result(C++11)(until C++20)(C++17) type_identity(C++20) Compile-time rational arithmetic Compile-time integer sequences integer_sequence(C++14) [edit]  Defined in header template struct is_empty; (since C++11)

If T is an empty type (that is, a non-union class type with no non-static data members other than bit-fields of size 0, no virtual functions, no virtual base classes, and no non-empty base classes), provides the member constant value equal to true. For any other type, value is false.

If T is a non-union class type, T shall be a complete type; otherwise, the behavior is undefined.

The behavior of a program that adds specializations for is_empty or is_empty_v (since C++17) is undefined.

Contents 1 Template parameters 2 Helper variable template 3 Inherited from std::integral_constant 3.1 Member constants 3.2 Member functions 3.3 Member types 3.4 Notes 3.5 Example 3.6 See also [edit] Template parameters T - a type to check [edit] Helper variable template template inline constexpr bool is_empty_v = is_empty::value; (since C++17) [edit] Inherited from std::integral_constant Member constants value[static] true if T is an empty class type , false otherwise (public static member constant) Member functions operator bool converts the object to bool, returns value (public member function) operator()(C++14) returns value (public member function) Member types Type Definition value_type bool type std::integral_constant [edit] Notes

Inheriting from empty base classes usually does not increase the size of a class due to empty base optimization.

std::is_empty and all other type traits are empty classes.

[edit] Example Run this code #include #include   struct A {};   struct B { int m; };   struct C { static int m; };   struct D { virtual ~D(); };   union E {};   struct F { [[no_unique_address]] E e; };   struct G { int:0; // C++ standard allow "as a special case, an unnamed bit-field with a width of zero // specifies alignment of the next bit-field at an allocation unit boundary. // Only when declaring an unnamed bit-field may the width be zero." };   int main() { std::cout


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3